package com.dominator.serviceImpl;

import com.dominFramework.core.typewrap.Dto;
import com.dominFramework.core.utils.SystemUtils;
import com.dominator.enums.ReqEnums;
import com.dominator.mybatis.dao.T_shopDao;
import com.dominator.mybatis.dao.T_shopPO;
import com.dominator.service.ApiShopService;
import com.dominator.utils.api.ApiMessage;
import com.dominator.utils.api.ApiMessageUtil;
import com.dominator.utils.api.ApiUtils;
import com.dominator.utils.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class ApiShopServiceImpl implements ApiShopService {

    @Autowired
    T_shopDao t_shopDao;

    @Override
    public ApiMessage getShopById(Dto dto) throws ApiException {
        ApiUtils.checkParam(dto, "shopId");
        T_shopPO shop = t_shopDao.selectByKey(dto.getString("shopId"));
        if (SystemUtils.isEmpty(shop)) {
            log.error("商户不存在");
            throw new ApiException(ReqEnums.REQ_RESULT_NULL);
        }
        return ApiMessageUtil.success(shop);
    }
}
